<?php
namespace App\Http\Controllers;

use App\Models\Address;
use App\Services\BaiduMapService;
use App\Services\LayoutRecommendService;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Validator;

/**
 *
 * 推荐位控制器
 *
 * @author maqu
 *
 */
class LayoutRecommendController extends BaseController {

    /**
     * 获取市级首页数据
     * @return mixed
     */
    public function getLayoutRecommends(BaiduMapService $mapService,LayoutRecommendService $layoutService ){

        //参数
        //【经纬度】
        //    lat   经度
        //    lon   维度
        //【查询等级】
        //    level city or country

        $lat =Input::get('lat',999);
        $lon =Input::get('lon',999);
//        $level =Input::get('level','city');
        $province = Input::get('province');
        $city = Input::get('city');
        $country =Input::get('district');
        $firstrow =Input::get('firstrow',0);
        $pagesize =Input::get('pagesize',10);
//		$cityname = Input::get('cityname');
		
		if($lat=='undefined'){
			$lat = 999;
		}
		if($lon=='undefined'){
			$lon = 999;
		}
		
//        $location = $mapService->locationByGPS($lon,$lat);
//        if(!$location){
//            return $this->failure('根据定位获取城市失败。');
//        }

        //精彩推荐
        $data['recommends'] = $layoutService->getLayoutRecommends($province, $city,$country,$firstrow,$pagesize);

        return $this->success($data);

    }

}
